import { createWebHistory, createRouter } from 'vue-router';
// import Layout from "@/layout";

/**
 * Note: 路由配置项
 *
 * hidden: true                     // 当设置 true 的时候该路由不会再侧边栏出现 如401，login等页面，或者如一些编辑页面/edit/1
 * alwaysShow: true                 // 当你一个路由下面的 children 声明的路由大于1个时，自动会变成嵌套的模式--如组件页面
 *                                  // 只有一个时，会将那个子路由当做根路由显示在侧边栏--如引导页面
 *                                  // 若你想不管路由下面的 children 声明的个数都显示你的根路由
 *                                  // 你可以设置 alwaysShow: true，这样它就会忽略之前定义的规则，一直显示根路由
 * redirect: noRedirect             // 当设置 noRedirect 的时候该路由在面包屑导航中不可被点击
 * name:'router-name'               // 设定路由的名字，一定要填写不然使用<keep-alive>时会出现各种问题
 * query: '{"id": 1, "name": "ry"}' // 访问路由的默认传递参数
 * meta : {
    noCache: true                   // 如果设置为true，则不会被 <keep-alive> 缓存(默认 false)
    title: 'title'                  // 设置该路由在侧边栏和面包屑中展示的名字
    icon: 'svg-name'                // 设置该路由的图标，对应路径src/assets/icons/svg
    breadcrumb: false               // 如果设置为false，则不会在breadcrumb面包屑中显示
    activeMenu: '/system/user'      // 当路由设置了该属性，则会高亮相对应的侧边栏。
  }
 */

// 公共路由
export const constantRoutes = [
  // start
  {
    path: '/test1',
    component: () => import('@/views/uncertain/testProvince'),
    name: 'test1',
    meta: { title: 'test1', icon: 'fa-database' },
  },
  {
    path: '/test',
    component: () => import('@/views/uncertain/test'),
    name: 'test',
    meta: { title: '地震灾害现场调查与烈度评估', icon: 'fa-database' },
  },
  {
    path: '/intensityAssessment1',
    component: () => import('@/views/uncertain/intensityAssessment1'),
    name: 'intensityAssessment1',
    meta: { title: '地震灾害现场调查与烈度评估', icon: 'fa-database' },
  },
  {
    path: '/lossAssessment1',
    component: () => import('@/views/uncertain/lossAssessment1'),
    name: 'lossAssessment1',
    meta: { title: '地震灾害现场调查与损失评估测试', icon: 'fa-database' },
  },
  {
    path: '/geologicalDisaster1',
    component: () => import('@/views/uncertain/geologicalDisaster1'),
    name: 'geologicalDisaster1',
    meta: { title: '地震地质灾害评估成果', icon: 'fa-database' },
  },
  {
    path: '/riskZonation1',
    component: () => import('@/views/uncertain/riskZonation1'),
    name: 'riskZonation1',
    meta: { title: '全国地震灾害风险区划图', icon: 'fa-database' },
  },
  // {
  //   path: '/vnlnerability1',
  //   component: () => import('@/views/uncertain/vnlnerability1'),
  //   name: 'vnlnerability1',
  //   meta: { title: '全国承灾体易损性数据', icon: 'fa-database' },
  // },
  // end
  {
    path: '/redirect',
    // component: Layout,
    hidden: true,
    children: [
      {
        path: '/redirect/:path(.*)',
        component: () => import('@/views/redirect/index.vue'),
      },
    ],
  },
  {
    path: '/login',
    component: () => import('@/views/login'),
    hidden: true,
  },
  {
    path: '/:pathMatch(.*)*',
    component: () => import('@/views/error/404'),
    hidden: true,
  },
  {
    path: '/401',
    component: () => import('@/views/error/401'),
    hidden: true,
  },
  {
    path: '/',
    redirect: '/largeScreenIndex',
    component: () => import('@/views/largeScreenIndex'),
    name: 'Index',
    meta: { title: '大屏首页', icon: 'fa-home-lg-alt', affix: true },
  },
  {
    path: '/index',
    component: () => import('@/views/index'),
    name: 'index',
    meta: { title: '首页', icon: 'fa-home-lg-alt', affix: true },
  },
  {
    path: '/largeScreenIndex',
    component: () => import('@/views/largeScreenIndex'),
    name: 'LargeScreenIndex',
    meta: { title: '大屏首页', icon: 'fa-database' },
  },
  {
    path: '/importantIndex',
    component: () => import('@/views/importantIndex'),
    name: 'importantIndex',
    meta: { title: '重大活动', icon: 'fa-database' },
  },
  {
    path: '/important',
    component: () => import('@/views/important'),
    name: 'important',
    meta: { title: '重大活动2', icon: 'fa-database' },
  },
  {
    path: '/securityActivity',
    component: () => import('@/views/securityActivity'),
    name: 'SecurityActivity',
    meta: { title: '安保活动', icon: 'fa-database' },
  },
  {
    path: '/disasterLosses',
    component: () => import('@/views/disasterLosses'),
    name: 'DisasterLosses',
    meta: { title: '全国设定地震灾害损失分布图', icon: 'fa-database' },
  },
  {
    path: '/disasterLosses/samplingPoint',
    component: () => import('@/views/samplingPoint'),
    name: 'samplingPoint',
    meta: { title: '全国预评估现场抽样调查点分布图', icon: 'fa-database' },
  },
  {
    path: '/disasterLosses/samplingPoint/provincePreEvaluation',
    component: () => import('@/views/provincePreEvaluation'),
    name: 'provincePreEvaluation',
    meta: { title: '', icon: 'fa-database' },
  },
  {
    path: '/housingFacilities',
    component: () => import('@/views/housingFacilities'),
    name: 'housingFacilities',
    meta: { title: '全国房屋设施数据', icon: 'fa-database' },
  },
  {
    path: '/buildHouse',
    component: () => import('@/views/buildHouse'),
    name: 'buildHouse',
    meta: { title: '全国房屋加固改造信息', icon: 'fa-database' },
  },
  {
    path: '/activeFault',
    component: () => import('@/views/activeFault'),
    name: 'activeFault',
    meta: { title: '全国活动断层分布图', icon: 'fa-database' },
  },
  {
    path: '/activeFault/second',
    component: () => import('@/views/activeFault/second'),
    name: 'activeFaultSecond',
    meta: { title: '各省活动断层分布图' }
  },
  {
    path: '/vulnerability',
    component: () => import('@/views/vulnerability'),
    name: 'vulnerability',
    meta: { title: '全国承灾体易损性数据', icon: 'fa-database' },
  },
  {
    path: '/vulnerability/subpage1',
    component: () => import('@/views/vulnerability/subpage1'),
    name: 'vulnerabilitySubpage1',
    meta: { title: '全国承灾体易损性数据', icon: 'fa-database' },
  },
  {
    path: '/vulnerability/subpage2',
    component: () => import('@/views/vulnerability/subpage2'),
    name: 'vulnerabilitySubpage2',
    meta: { title: '全国承灾体易损性数据', icon: 'fa-database' },
  },
  {
    path: '/geologicalDisaster',
    component: () => import('@/views/geologicalDisaster'),
    name: 'geologicalDisaster',
    meta: { title: '地震地质灾害评估成果', icon: 'fa-database' },
  },
  {
    path: '/geologicalDisaster/second',
    component: () => import('@/views/geologicalDisaster/second'),
    name: 'geologicalDisasterSecond',
    meta: { title: '各省地震地质灾害评估成果' }
  },
  {
    path: '/riskZonation',
    component: () => import('@/views/riskZonation'),
    name: 'riskZonation',
    meta: { title: '全国地震灾害风险区划图', icon: 'fa-database' },
  },
  {
    path: '/lossAssessment',
    component: () => import('@/views/lossAssessment'),
    name: 'lossAssessment',
    meta: { title: '地震灾害现场调查与损失评估', icon: 'fa-database' },
  },
  {
    path: '/intensityAssessment',
    component: () => import('@/views/intensityAssessment'),
    name: 'intensityAssessment',
    meta: { title: '地震灾害现场调查与烈度评估', icon: 'fa-database' },
  },
  {
    path: '/intensityAssessment/subpage1',
    component: () => import('@/views/intensityAssessment/subpage1'),
    name: 'intensityAssessmentSubpage1',
    meta: { title: '地震烈度评定结果及调查数据', icon: 'fa-database' },
    path: '/intensityAssessment/siarSurveyData',
    component: () => import('@/views/siarSurveyData'),
    name: 'siarSurveyData',
    meta: { title: '地震灾害现场调查与烈度评估', icon: 'fa-database' },
  },
  {
    path: '/projectDrill',
    component: () => import('@/views/projectDrill'),
    name: 'projectDrill',
    meta: { title: '全国地震安全性评价和钻孔位置分布图', icon: 'fa-database' },
  },
  {
    path: '/basicData/:type?',
    component: () => import('@/views/basicData'),
    name: 'basicData',
    meta: { title: '全国基础数据分布图', icon: 'fa-database' },
  },
  {
    path: '/buildHouse/houseNew',
    component: () => import('@/views/buildHouse/second/houseNew'),
    name: 'houseNew',
    meta: { title: '全国房屋新建工程数据', icon: 'fa-database' },
  },
  {
    path: '/buildHouse/houseReinforce',
    component: () => import('@/views/buildHouse/second/houseReinforce'),
    name: 'houseReinforce',
    meta: { title: '全国房屋加固工程数据', icon: 'fa-database' },
  },
  {
    path: '/buildHouse/reinforceClassicCase',
    component: () => import('@/views/buildHouse/second/reinforceClassicCase'),
    name: 'reinforceClassicCase',
    meta: { title: '全国房屋加固改造典型案例', icon: 'fa-database' },
  },
  {
    path: '/buildHouse/reinforceClassicCase/caseDetails',
    component: () => import('@/views/buildHouse/third/caseDetails'),
    name: 'caseDetails',
    meta: { title: '典型案例详情信息', icon: 'fa-database' },
  },
  {
    path: '/housingFacilities/sift',
    component: () => import('@/views/housingFacilities/second/sift'),
    name: 'housingFacilitiesSift',
    meta: { title: '全国房屋详查数据', icon: 'fa-database' },
  },
  {
    path: '/housingFacilities/census',
    component: () => import('@/views/housingFacilities/second/census'),
    name: 'housingFacilitiesCensus',
    meta: { title: '全国房屋普查数据', icon: 'fa-database' },
  },
];

const router = createRouter({
  history: createWebHistory('ywpt'),
  routes: constantRoutes,
  scrollBehavior(to, from, savedPosition) {
    if (savedPosition) {
      return savedPosition;
    } else {
      return { top: 0 };
    }
  },
});

export default router;
